home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
shellcal.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
3KB
|
99 lines
IMPLEMENTATION MODULE ShellCall;
FROM SysUtil1 IMPORT SuperPeek;
FROM SYSTEM IMPORT CALLEXT, ADR, ADDRESS, LOAD, STORE;
FROM Characters IMPORT CR, LF;
IMPORT MagicDOS, mtCommand, MagicStrings, MagicAES;
IMPORT CatGlobal;
IMPORT ARCStarter;
CONST _shell_p = ADDRESS($4f6);
PROCEDURE system(ptr : ADDRESS):INTEGER;
VAR doSys : ADDRESS;
res : INTEGER;
(* Xbra ? *)
BEGIN
IF CatGlobal.multiTask THEN RETURN -1 END;
SuperPeek(_shell_p, doSys);
IF ptr = NIL THEN
IF LONGCARD(doSys) # 0 THEN RETURN 0 ELSE RETURN -1 END;
ELSIF doSys # 0 THEN
CALLEXT (doSys, ptr);
STORE (0,res);
RETURN res;
ELSE RETURN -1;
END;
END system;
PROCEDURE CallShell(VAR str : ARRAY OF CHAR; withRedirection: BOOLEAN);
VAR shellName: ARRAY [0..255] OF CHAR;
cmd : ARRAY [0..255] OF CHAR;
tosRun : ARRAY [0..255] OF CHAR;
res : INTEGER;
BEGIN
IF system(ADR(str)) = -1 THEN
IF mtCommand.EnvVar (mtCommand.EnvShell, shellName)
THEN
MagicStrings.Assign (str, cmd);
MagicStrings.Insert ('"', cmd, 0);
MagicStrings.Append ('"', cmd);
MagicStrings.Insert (" -c ", cmd, 0);
cmd[0] := CHR(LENGTH (cmd));
IF withRedirection
THEN
ARCStarter.ExecProgram (shellName, cmd, FALSE, ~withRedirection, FALSE, res);
ELSE
IF LENGTH (str) > 0
THEN
MagicStrings.Assign (str, cmd);
MagicStrings.Insert ('"', cmd, 0);
MagicStrings.Append ('"', cmd);
MagicStrings.Insert (" -c ", cmd, 0);
ELSE
cmd[0] := 0C;
END;
(* Keine IO-Redirection! *)
IF CatGlobal.multiTOS & mtCommand.EnvVar ('TOSRUN=', tosRun)
THEN
(* TOSRUN auslesen und Shell darin starten *)
MagicStrings.Insert (shellName, cmd, 0);
MagicStrings.Insert (" ", cmd, 0);
cmd[0] := CHR(LENGTH (cmd));
res := MagicAES.ShelWrite(0,1,1, tosRun, cmd);
ELSIF CatGlobal.magIx & (CatGlobal.magIxVer >= $200)
THEN
IF LENGTH (cmd) > 0
THEN
cmd[0] := CHR(LENGTH (cmd));
END;
(* ShelWrite auf TOS-Programm ausfhren *)
res := MagicAES.ShelWrite(1,0,100, shellName, cmd);
ELSE
IF LENGTH (cmd) > 0
THEN
cmd[0] := CHR(LENGTH (cmd));
END;
ARCStarter.ExecProgram (shellName, cmd, FALSE, TRUE, FALSE, res);
END;
END;
ELSE
MagicDOS.Cconout(CR); MagicDOS.Cconout(LF);
MagicDOS.Cconws('Es ist keine Shell verfgbar!');
END;
END;
END CallShell;
PROCEDURE IsShell(): shellType;
VAR shellName: ARRAY [0..255] OF CHAR;
BEGIN
IF system(NIL) >= 0 THEN RETURN shellP
ELSIF mtCommand.EnvVar (mtCommand.EnvShell, shellName)
THEN RETURN shellProg
END;
RETURN noShell;
END IsShell;
END ShellCall.